package com.atguigu.lease.web.admin.config;

import com.atguigu.lease.common.converter.StringToBaseEnumConverterFactory;
import com.atguigu.lease.common.converter.StringToItemTypeConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created by 小可乐$ on 2024/8/12$ 16:27$
 * description:注册格式化器，枚举类转换
 */
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

    @Autowired//枚举类转化类工厂
    private StringToBaseEnumConverterFactory stringToBaseEnumConverterFactory;
    @Override
    public void addFormatters(FormatterRegistry registry) {
//        注册转换器
//        registry.addConverter(this.stringToItemTypeConverter);
        registry.addConverterFactory(this.stringToBaseEnumConverterFactory);
    }
}
